﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BTicino.BtCommLib.Mappers;

namespace BTicino.BtCommLib.Test
{
    /// <summary>
    /// This class is used to translate from high level language to BTicino "WHO"
    /// code parameter and viceversa.
    /// </summary>
    public class MyWhoMapper : IMapper
    {
        // Dictionary from high level to BTicino low level messages
        private Dictionary<string, string> dictToLowLevel = new Dictionary<string, string>();
        // Dictionary from BTicino low level to high level messages
        private Dictionary<string, string> dictToHighLevel = new Dictionary<string, string>();

        public MyWhoMapper()
        {
            dictToLowLevel.Add("Scenario", "0");
            dictToLowLevel.Add("Light", "1");
            dictToLowLevel.Add("Automation", "2");
            dictToLowLevel.Add("Termo", "4");
     

            dictToHighLevel.Add("0", "Scenario");
            dictToHighLevel.Add("1", "Light");
            dictToHighLevel.Add("2", "Automation");
            dictToHighLevel.Add("4", "Termo");
       
        }

        /// <summary>
        /// Traslator from high level message to low level message. For specific messages it need the
        /// HighLevelCtxAttr object to discriminate correct value 
        /// </summary>
        /// <param name="key">Key string, it allows to find low level message associate to specifi high level message</param>
        /// <param name="ctxAttr">Object contains other frame information (eg. WHO, WHAT, etc...)</param>
        /// <returns>Low level message</returns>
        public string GetValueToLowLevel(string key, HighLevelCtxAttr ctxAttr)
        {
            return dictToLowLevel[key];
        }

        /// <summary>
        /// Traslator from low level message to high level message. For specific messages it need the
        /// LowLevelCtxAttr object to discriminate correct value 
        /// </summary>
        /// <param name="key">Key string, it allows to find high level message associate to specifi low level message</param>
        /// <param name="ctxAttr">Object contains other frame information (eg. WHO, WHAT, etc...)</param>
        /// <returns>High level message</returns>
        public string GetValueToHighLevel(string key, LowLevelCtxAttr ctxAttr)
        {
            return dictToHighLevel[key];
        }
    }
}